<template>
	<view class="online_order" style="padding-bottom: 250rpx;">
		<!-- 导航 -->
		<!-- <u-navbar back-icon-color="#000000" title="立即下单" title-color="#3F3F3F" :title-bold="true" :border-bottom="false" :background="background"></u-navbar> -->
		<u-navbar back-text="立即下单" :back-text-style="textStyle" back-icon-color="#000000" style="font-weight: bold;font-family: PingFang SC;"></u-navbar>
		<!-- end -->
		<view v-if="shows" style="text-align: center;padding-bottom: 100rpx;">
			<view style="padding: 70rpx 0 24rpx 0;">还没有地址哦~快去添加地址吧~</view>
			<u-button size="medium" shape="circle" :plain="true" type="warning" @click="adds()">去添加地址</u-button>
		</view>
		<view v-else>
			<view class="biaozhu">
				<image src="../../static/icon/gantan.png" mode=""></image>
				<view class="write" style="margin-left: 22rpx;">地址会做隐私处理，订单确认前不会告知商家详细地址</view>
			</view>
			<view class="head">
				<view style="font-weight: bold;color: #7A7A7A;">
					<text class="namm" style="font-size: 30rpx;">{{ address.contactsName }}</text>
					<text class="namm" style="font-size: 26rpx;padding-left: 20rpx;">{{ address.contactsPhone }}</text>
				</view>
				<view class="serve" style="color: #7A7A7A;font-size: 26rpx;">
					<view style="width: 23%;">服务地址：</view>
					<view class="fuwu" style="width: 77%;" @click="getAddress()">
						<!-- <view class="dizhi">{{address.province}}{{address.city}}{{address.region}}{{address.address}}</view> -->
						<view class="dizhi">{{ address.province }}{{ address.city }}{{ address.region }}{{ address.address }}</view>
						<u-icon name="arrow-right" color="#707070" size="20"></u-icon>
					</view>
				</view>
				<view class="contact" style="color: #7A7A7A;font-size: 26rpx;">
					<text class="xiang" style="width: 23%;">详细地址：</text>
					<text style="display: inline-block;width: 77%;" class="ads">{{ address.address }}</text>
				</view>
			</view>
		</view>

		<image src="../../static/icon/dixian.png" mode="" style="width: 100%;height: 4rpx;"></image>
		<view class="" style="width: 91%;margin:32rpx auto;">
			<view @click="goShopDetail" style="width: 100%;display: flex;align-items: center;justify-content: space-between;">
				<view style="font-size:30rpx;color: #000000;">{{ name }}</view>
				<view><u-icon name="arrow-right" color="#707070" size="28"></u-icon></view>
			</view>
			<view style="width: 100%;display: flex;align-items: center;justify-content: space-between;margin-top: 10rpx;">
				<view style="font-size:30rpx;color: #272755;">{{ titleName }}</view>
				<view style="font-size:30rpx;color: #FC7E00;">
					￥
					<text style="font-weight: bold;">{{ xinxidata.univalence || '' }}</text>
					{{ xinxidata.univalenceUnit }}
				</view>
			</view>
		</view>
		<view style="width: 100%;height: 2rpx ;background-color:#E4E7EB ;"></view>
		<!-- 日常保洁 -->
		<view style="width: 91%;margin:32rpx auto;" v-if="chargeType == 1">
			<view class="" style="display: flex;">
				<text style="color:#3F3F3F ;font-size: 30rpx;">请选择服务时长（下面为参考时长）</text>
				<view style="width: 120rpx;"><u-number-box v-model="choose_time" @change="valChange"></u-number-box></view>
			</view>
			<view class="fenlei">
				<view class="" style="text-align: center;" v-for="(item, index) in typeList" :key="index" :data-id="item.id" @click="detal(item.time, index)">
					<view class="type" :class="inde == item.id ? 'acts' : 'acts_2'">
						{{ item.type }}
						<!-- <image src="../../static/icon/gou.png" mode="" v-if="inde == item.id"></image> -->
					</view>
					<view class="tai" style="margin-top: 18rpx;" :class="{ actss: inde == item.id }">{{ item.time }}小时</view>
				</view>
			</view>
		</view>
		<!-- 家电清洗 -->

		<view v-if="chargeType == 3" style="width: 91%;margin:32rpx auto;">
			<view style="  margin: auto; display: flex;align-items: center;justify-content: space-between;">
				<view class="" style="color: #3F3F3F;font-size: 30rpx;">请选择服务数量</view>
				<view style="color: #272755;font-size: 26rpx;display: flex;align-items: center;">
					<u-number-box v-model="choose_num" @change="valChange_jd"></u-number-box>
					<!-- <view style="margin-left: 10rpx;">台</view> -->
				</view>
			</view>

			<view class="fenlei" style="padding: 30rpx 0rpx;">
				<view
					class=""
					style="text-align: center;"
					v-for="(item, index) in xinxidata.specificList"
					:key="index"
					:data-id="item.specificId"
					@click="detals(item.specificPrice, item.specificId, index)"
				>
					<view class="type" :class="indes == item.specificId ? 'acts' : 'acts_2'">{{ item.specificName }}</view>
				</view>
			</view>

			<!-- 	<view class="" style="color: #3F3F3F;font-size: 30rpx;">请选择清洗数量</view>
			
			<view class="fenlei">
				<view
					class=""
					style="text-align: center;"
					v-for="(item, index) in xinxidata.specificList"
					:key="index"
					:data-id="item.specificId"
					@click="detals(item.specificPrice, item.specificId, index)"
				>
					<view class="type" :class="{ acts: indes == item.specificId }">{{ item.name }}</view>
					<view class="tai" :class="{ actss: indes == item.specificId }">{{ item.specificPrice }}{{ xinxidata.univalenceUnit }}</view>
				</view>
			</view>

			<view style="color: #272755;font-size: 26rpx;display: flex;align-items: center;">
				<u-number-box v-model="choose_num" @change="valChange_jd()"></u-number-box>
				<view style="margin-left: 10rpx;">台</view>
			</view> -->
		</view>
		<!-- 布艺清洗 -->
		<view v-if="chargeType == 2">
			<!-- 	<view class="choose">输入清洁面积</view> -->
			<!-- <view class="fen_types">
				<input type="text" value="" v-model="area" @input="onInput" />
				㎡
			</view> -->

			<view style="display: flex;padding: 20rpx 0rpx;width: 92%;margin: auto; align-items: center;justify-content: space-between;">
				<view class="" style="color: #3F3F3F;font-size: 30rpx;">输入清洁面积</view>
				<view class="fen_types" style="color: #3F3F3F;font-size: 30rpx;">
					<input type="text" value="" v-model="area" @input="onInput" />
					㎡
				</view>
			</view>
			<view style="width: 100%;height: 1rpx;background-color: #E4E7EB;"></view>

			<view v-if="titleName == '玻璃清洗'" style="display: flex;width: 92%;margin: auto;padding: 20rpx 0;align-items: center;justify-content: space-between;">
				<view class="" style="color: #3F3F3F;font-size: 30rpx;">
					纱窗数量({{ additional[0].additionalPrice }}
					<!-- {{ additional[0].additionalUnit }} -->
					元 )
				</view>
				<view class="fen_types" style="color: #3F3F3F;font-size: 30rpx;">
					<input type="text" value="" v-model="area_sc" @input="onInput2" />
					个
				</view>
			</view>
			<view v-if="titleName == '玻璃清洗'" style="width: 100%;height: 1rpx;background-color: #E4E7EB;"></view>
		</view>
		<view style="width: 100%;height: 2rpx ;background-color:#E4E7EB ;"></view>
		<view class="time" style="align-items: center;justify-content: space-between;">
			<view style="display: flex;align-items: center;">
				<image style="width:24rpx ;height: 24rpx;margin-right: 10rpx;" src="../../static/gx_img/xiadan_1.png"></image>
				<view class="start">选择开始时间</view>
			</view>
			<view class="xuanze" @click="is_show()">
				<u-select
					style="line-height: 32rpx;width: 4%;"
					title="选择开始时间"
					v-model="show"
					mode="mutil-column-auto"
					:list="list"
					confirm-color="#FCC800"
					@confirm="confirm"
				></u-select>
				<view class="">{{ result }}</view>
				<image style="width: 14rpx;height: 24rpx;margin-left: 25rpx;" src="../../static/icon/jian.png" mode=""></image>
			</view>
		</view>
		<view style="width: 91%;margin:25rpx auto;display: flex;align-items: center;justify-content: space-between;">
			<view style="display: flex;align-items: center;">
				<image style="width:24rpx ;height: 20rpx;margin-right: 10rpx;" src="../../static/gx_img/xiadan_2.png"></image>
				<view class="start">优惠券</view>
			</view>
			<view @tap="jump_yhq" class="xuanze">
				<view class="" v-if="juq_numer > 0">
					<text v-if="yhj_sy">-￥{{ yhj_sy }}</text>
					<text v-else>{{ juq_numer }}张可用优惠券</text>
				</view>

				<view class="" v-else>暂无可用优惠券</view>
				<image style="width: 14rpx;height: 24rpx;margin-left: 25rpx;" src="../../static/icon/jian.png" mode=""></image>
			</view>
		</view>
		<view style="width: 91%;margin: auto;display: flex;align-items: center;justify-content: space-between;">
			<view style="display: flex;align-items: center;">
				<image style="width:22rpx ;height: 24rpx;margin-right: 10rpx;" src="../../static/gx_img/xiandan_3.png"></image>
				<view class="start">积分抵扣（可使用{{ xinxidata.usedBalances || '0' }}积分抵扣{{ (0.1 * xinxidata.usedBalances).toFixed(2) || '0' }}元）</view>
			</view>
			<view class="" style="margin-right: -15rpx;">
				<label @click="radioChange()" style="font-size:28upx;text-align: right;">
					<radio style="transform: scale(0.7);" color="#FFC000" value="r" :checked="checkeds" />
				</label>
			</view>
		</view>
		<view style="display: flex;justify-content: space-between;" v-if="isShow">
			<view></view>
			<view class="biaozhus">
				<image src="../../static/icon/gantan.png" mode=""></image>
				<view class="write" style="margin-left: 22rpx;">{{ fuheNum == 1 ? '地毯清洁最低40平方米' : '未选择时间' }}</view>
			</view>
		</view>
		<!-- <view class="biao_zhu">
			<view class="zhu">服务须知：</view>
			<view class="write">服务人员上门后会再次确认服务内容，出现偏差后进行多退少补</view>
		</view>
 -->
		<view class="footer" style="padding: 24rpx;border-top: 1rpx solid #F5F5F5;">
			<view class="foot_mon">
				<view class="writes">
					<text style="color: #F29423;font-size:30rpx;">￥</text>
					<text style="color: #F29423;font-size: 40rpx;font-weight: bold;">{{ (needPay * 1).toFixed(2) }}</text>
				</view>
				<view @click="is_mingxi()" style="display: flex;">
					<view>费用明细</view>
					<view style="margin-left: 10rpx;"><u-icon name="arrow-up" color="#707070" size="20"></u-icon></view>
				</view>
				<view
					@tap="fast()"
					style="width:258rpx;height: 88rpx;border-radius: 26rpx;background-color: #FCA800;text-align: center;font-size: 38rpx;color: white;line-height: 88rpx;"
				>
					立即下单
					<!-- 立即预约 -->
				</view>
			</view>
		</view>

		<u-popup mode="bottom" v-model="mingxi">
			<view style="width: 93%;margin: auto;display: flex;align-items: center;padding-top: 22rpx;justify-content: space-between;">
				<view style="color: #9393AA;font-size:24rpx;">费用明细：</view>
				<view @click="is_mingxi()"><image style="width: 30rpx;height: 30rpx;" src="../../static/gx_img/xiadan_4.png"></image></view>
			</view>

			<view class="content" style="width: 90%;margin: auto;padding-bottom: 100rpx;">
				<view>
					<view style="display: flex;align-items: center;justify-content: space-between;margin-top:30rpx ;">
						<view style="display: flex;align-items: center;">
							<image style="width:24rpx ;height: 24rpx;margin-right: 10rpx;" src="../../static/gx_img/xiadan_1.png"></image>
							<view class="start">服务费用</view>
						</view>
						<view class="">
							<view style="font-size: 24rpx;color: #9393AA;" class="">￥{{ (prices * 1).toFixed(2) }}</view>
						</view>
					</view>
					<view style="display: flex;align-items: center;justify-content: space-between;margin-top:30rpx ;">
						<view style="display: flex;align-items: center;">
							<image style="width:24rpx ;height: 20rpx;margin-right: 10rpx;" src="../../static/gx_img/xiadan_2.png"></image>
							<view class="start">优惠券</view>
						</view>
						<view class="">
							<view style="font-size: 24rpx;color: #9393AA;" class="">
								-￥
								<text v-if="yhj_sy">{{ yhj_sy }}</text>
								<text v-else>0</text>
							</view>
						</view>
					</view>
					<view style="display: flex;align-items: center;justify-content: space-between;margin-top:30rpx ;">
						<view style="display: flex;align-items: center;">
							<image style="width:22rpx ;height: 24rpx;margin-right: 10rpx;" src="../../static/gx_img/xiandan_3.png"></image>
							<view class="start">积分抵扣</view>
						</view>
						<view class="">
							<view style="font-size: 24rpx;color: #9393AA;" class="">
								-￥
								<text v-if="checkeds == true">{{ (1 * jifendk).toFixed(2) || '0' }}</text>
								<text v-else>0</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="foot_mon" style="width: 92%;margin: auto;padding-bottom: 22rpx;">
				<view class="writes">
					<text style="color: #F29423;font-size:30rpx;">￥</text>
					<text style="color: #F29423;font-size: 40rpx;font-weight: bold;">{{ (needPay * 1).toFixed(2) }}</text>
				</view>
				<view @click="is_mingxi()" style="display: flex;">
					<view>费用明细</view>
					<view style="margin-left: 10rpx;"><u-icon name="arrow-down" color="#707070" size="20"></u-icon></view>
				</view>
				<view
					@tap="fast()"
					style="width:278rpx;height: 88rpx;border-radius: 26rpx;background-color: #FCA800;text-align: center;font-size: 38rpx;color: white;line-height: 88rpx;"
				>
					立即下单
				</view>
			</view>
		</u-popup>
		<lodings v-if="loding_istrue"></lodings>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
import lodings from '../../components/loding_zdy.vue';

export default {
	components: {
		lodings
	},
	data() {
		return {
			loding_istrue: false,
			data1: null,
			background: {
				backgroundColor: '#fca800'
			},
			mingxi: false,
			choose_time: 2,
			choose_num: 1,
			show: false,
			list: [],
			// times:[],
			result: '请选择时间',
			title: 'picker',
			index: 0,
			twoindex: 0,
			arrayInex: [],
			type: 0,
			typeList: [
				{
					id: 1,
					type: '50㎡以内',
					time: '2'
				},
				{
					id: 2,
					type: '50㎡-90㎡',
					time: '3'
				},
				{
					id: 3,
					type: '91㎡-120㎡',
					time: '4'
				},
				{
					id: 4,
					type: '121㎡-150㎡',
					time: '5'
				},
				{
					id: 5,
					type: '大于150㎡',
					time: '6'
				}
			],
			inde: 1,
			address: {
				province: '',
				city: '',
				region: '',
				address: ''
			},
			tims: '',
			employeeId: '',
			businessId: '',
			price: '',
			prices: '0',

			chargeType: '',
			indes: '',
			typeLists: [
				{
					name: '家电清洗空调清洗拆洗/半拆洗'
				},
				{}
			],
			specificId: '',
			area: '',
			area_sc: '',
			supId: '',
			minPrice: '',
			maxPrice: '',
			zcxd: '',
			zcPrice: [],
			rcbjPrice: '',
			orderType: '',
			isShow: false,
			shows: false,
			checkeds: false,
			enterpriseId: '',
			xinxidata: '',
			additional: '',
			prices_sc: {
				maxAdditionalPrice: '',
				minAdditionalPrice: ''
			},
			titleName: '',
			name: '',
			price_addfj: 0,
			price_ss: 0,
			juq_numer: 0,
			byqx_numer: 1,
			xingqi_price: 0,
			usedBalances: 0,
			additionalId: '',
			businessAdditional: [],
			yhj_sy: '',
			needPay: '',
			jifendk: '',
			userCouponId: '',
			is_zhifu: true,
			isShop: 0,
			fuheNum: 0
		};
	},
	onShow() {
		if (this.data1) {
			this.yhj_sy = this.data1.price;
			this.userCouponId = this.data1.userCouponId;
			this.updataPrice();
		}
	},

	onLoad(option) {
		this.businessId = option.businessId;
		this.supId = option.supId;
		this.enterpriseId = option.enterpriseId;
		this.employeeId = option.employeeId;
		this.price = option.price;
		this.zcxd = option.zcxd;
		this.orderType = option.orderType;
		this.titleName = option.titleName;
		this.name = option.name;
		this.chargeType = option.chargeType;
		//判断是否从商家主页跳进来的
		if (option.isShop) {
			this.isShop = option.isShop;
		}
		// 地摊服务默认最低40平放米
		this.MatchingOrderInfo(); // 下单页面信息
		this.getDatas();
		this.getAddressList(); // 获取默认地址
		// this.getPrice(); // 获取价格区间
		// this.getAvailableQuantity()
	},

	methods: {
		is_show() {
			this.show = true;
		},
		updataPrice() {
			if (this.data1) {
			} else {
				this.data1 = {
					price: 0
				};
			}

			if (this.chargeType == 1) {
				if (this.usedBalances == 1) {
					if (parseFloat(this.xinxidata.univalence) * this.choose_time > parseFloat(this.xinxidata.usedBalances) * 0.1 + this.data1.price) {
						this.needPay = parseFloat(this.xinxidata.univalence) * this.choose_time - parseFloat(this.xinxidata.usedBalances) * 0.1 - this.data1.price;
					} else {
						this.needPay = 0;
					}
				} else {
					this.needPay = parseFloat(this.xinxidata.univalence) * this.choose_time - this.data1.price;
				}
				//布衣清洗
			} else if (this.chargeType == 2) {
				if (this.titleName == '玻璃清洗') {
					if (this.usedBalances == 1) {
						if (
							parseFloat(this.xinxidata.univalence) * this.area + parseFloat(this.additional[0].additionalPrice) * this.area_sc >
							parseFloat(this.xinxidata.usedBalances) * 0.1 + this.data1.price
						) {
							this.needPay =
								parseFloat(this.xinxidata.univalence) * this.area +
								parseFloat(this.additional[0].additionalPrice) * this.area_sc -
								parseFloat(this.xinxidata.usedBalances) * 0.1 -
								this.data1.price;
						} else {
							this.needPay = 0;
						}
					} else {
						this.needPay = parseFloat(this.xinxidata.univalence) * this.area + parseFloat(this.additional[0].additionalPrice) * this.area_sc - this.data1.price;
					}
				} else {
					if (this.usedBalances == 1) {
						if (parseFloat(this.xinxidata.univalence) * this.area > parseFloat(this.xinxidata.usedBalances) * 0.1 + this.data1.price) {
							this.needPay = parseFloat(this.xinxidata.univalence) * this.area - parseFloat(this.xinxidata.usedBalances) * 0.1 - this.data1.price;
						} else {
							this.needPay = 0;
						}
					} else {
						this.needPay = parseFloat(this.xinxidata.univalence) * this.area - this.data1.price;
					}
				}

				//chargeType==3油烟机清洗
			} else {
				if (this.usedBalances == 1) {
					if (parseFloat(this.xinxidata.univalence) * this.choose_num > parseFloat(this.xinxidata.usedBalances) * 0.1 + this.data1.price) {
						this.needPay = parseFloat(this.xinxidata.univalence) * this.choose_num - parseFloat(this.xinxidata.usedBalances) * 0.1 - this.data1.price;
					} else {
						this.needPay = 0;
					}
				} else {
					this.needPay = parseFloat(this.xinxidata.univalence) * this.choose_num - this.data1.price;
				}
			}
		},
		is_mingxi() {
			this.mingxi = !this.mingxi;
		},
		jump_yhq() {
			uni.navigateTo({
				url: '../personal/choose_yhq?businessId=' + this.businessId + '&enterpriseId=' + this.enterpriseId + '&amountMoney=' + this.prices
			});
		},
		// 去商家主页
		goShopDetail(){
			//判断是否从商家主页进入的
			if(this.isShop == 1){
				uni.navigateBack({
					delta:1
				})
			}else{
				uni.navigateTo({
					url: '../home/shopDetails/shopDetails?enterpriseId=' + this.enterpriseId  
				})
			}
		},
		// 下单页面信息
		MatchingOrderInfo() {
			let opts = {
				way: true, //true JSON请求；false 表单请求
				method: 'post',
				url: 'unit-orders/dailyOrderInfo'
			};
			let data = {
				businessId: this.businessId,
				entId: this.enterpriseId
			};
			this.http.httpTokenRequest(opts, data).then(res => {
				//打印请求返回的数据
				if (res.code == '200') {
					this.maxPrice = res.data.maxPrice;
					this.minPrice = res.data.minPrice;
					this.xinxidata = res.data;
					this.additional = res.data.additional;
					if (this.chargeType == 1) {
						this.inde = 1;
						this.prices = 2 * parseFloat(this.xinxidata.univalence);
						if (this.prices) {
							this.getAvailableQuantity();
						}
						if (this.usedBalances == 1) {
							if (this.prices >= 0.1 * this.xinxidata.usedBalances) {
								this.needPay = this.prices - 0.1 * this.xinxidata.usedBalances;
							} else {
								this.needPay = 0;
							}
						} else {
							this.needPay = this.prices;
						}
					} else if (this.chargeType == 2) {
					} else {
						this.typeLists = this.xinxidata.specificList;
						this.detals(this.typeLists[0].specificPrice, this.typeLists[0].specificId, 0);
						if (this.prices) {
							this.getAvailableQuantity();
						}
						this.xinxidata.univalence = this.typeLists[0].specificPrice;
					}
					if (this.businessId == '28') {
						this.area = '40';
						var detail = {
							value: this.area
						};
						var form = {
							detail: detail
						};
						this.onInput(form);
					}
				} else {
					this.$refs.uToast.show({
						title: res.message,
						type: 'error'
					});
				}
			});
		},
		//用户可用优惠券数量
		getAvailableQuantity() {
			let opts = {
				way: true, //true JSON请求；false 表单请求
				method: 'post',
				url: 'coupon/getAvailableQuantity'
			};
			let data = {
				specificId: this.specificId,
				amount: this.tims || this.area || this.choose_num,
				businessId: this.businessId,
				enterpriseId: this.enterpriseId,
				amountMoney: this.prices
			};
			this.http.httpTokenRequest(opts, data).then(res => {
				//打印请求返回的数据
				if (res.code == '200') {
					this.juq_numer = res.data;
				} else {
					this.$refs.uToast.show({
						title: res.message,
						type: 'error'
					});
				}
			});
		},

		radioChange(e) {
			this.checkeds = !this.checkeds;
			if (this.checkeds == true) {
				this.usedBalances = 1;
				if (this.needPay > 0.1 * this.xinxidata.usedBalances) {
					this.needPay = this.needPay - 0.1 * this.xinxidata.usedBalances;
					this.jifendk = 0.1 * this.xinxidata.usedBalances;
				} else {
					if (this.yhj_sy) {
						this.jifendk = this.prices - this.yhj_sy;
					} else {
						this.jifendk = this.prices;
					}

					this.needPay = 0;
				}
			} else {
				if (this.yhj_sy) {
					this.needPay = this.prices - this.yhj_sy;
				} else {
					this.needPay = this.prices;
				}

				this.usedBalances = 0;
			}
		},
		valChange(e) {
			this.yhj_sy = '';
			this.byqx_numer = e.value;
			this.tims = e.value;
			this.prices = this.byqx_numer * this.xinxidata.univalence;
			this.data1 = null;
			if (this.usedBalances == 1) {
				if (this.prices >= 0.1 * this.xinxidata.usedBalances) {
					this.needPay = this.prices - 0.1 * this.xinxidata.usedBalances;
				} else {
					this.needPay = 0;
				}
			} else {
				this.needPay = this.prices;
			}
			if (e.value != 2 && e.value != 3 && e.value != 4 && e.value != 5 && e.value != 6) {
				this.inde = '';
			}
			if (e.value == 2 || e.value == 3 || e.value == 4 || e.value == 5 || e.value == 6) {
				this.inde = e.value - 1;
			}

			if (this.prices) {
				this.getAvailableQuantity();
			}
			//
		},
		valChange_jd(e) {
			this.yhj_sy = '';
			this.choose_num = e.value;
			this.prices = this.xingqi_price * this.choose_num;
			this.data1 = null;
			if (this.usedBalances == 1) {
				if (this.prices >= 0.1 * this.xinxidata.usedBalances) {
					this.needPay = this.prices - 0.1 * this.xinxidata.usedBalances;
				} else {
					this.needPay = 0;
				}
			} else {
				this.needPay = this.prices;
			}
			if (this.prices) {
				this.getAvailableQuantity();
			}
		},
		//点击确定的值
		confirm(e) {
			this.result = e[0].label + ' ' + e[1].label;
			if(this.area < 40 && this.businessId=='28'){
				this.isShow = true;
			}else{
				this.isShow = false;
			}
		},
		cancel(e) {},
		getAddressList() {
			let opts = {
				way: true, //true JSON请求；false 表单请求
				method: 'post',
				url: 'user-address/first'
			};
			this.http.httpTokenRequest(opts).then(res => {
				//打印请求返回的数据
				if (res.code == '200') {
					if (res.data) {
						this.address = res.data;
						this.shows = false;
					} else {
						this.shows = true;
					}
				}
			});
		},
		adds() {
			uni.navigateTo({
				url: '../personal/addAddress?type=0'
			});
		},
		getAddress() {
			uni.navigateTo({
				url: '../personal/address?type=1'
			});
		},
		// 日常保洁
		detal(time, index) {
			this.yhj_sy = '';
			this.tims = time;
			this.choose_time = time;
			this.indexs = index + 1;
			this.inde = this.indexs;
			this.byqx_numer = time;
			this.prices = this.xinxidata.univalence * time;
			if (this.prices) {
				this.getAvailableQuantity();
			}

			this.data1 = null;
			if (this.usedBalances == 1) {
				if (this.prices >= 0.1 * this.xinxidata.usedBalances) {
					this.needPay = this.prices - 0.1 * this.xinxidata.usedBalances;
				} else {
					this.needPay;
				}
			} else {
				this.needPay = this.prices;
			}
		},
		// 冰箱清洗
		detals(univalence, specificId, index) {
			this.yhj_sy = '';
			this.specificId = specificId;
			this.xinxidata.univalence = univalence;
			this.detals_indexs = index + 1;
			// this.indes = this.detals_indexs
			this.indes = specificId;
			this.xingqi_price = univalence;
			this.prices = this.xingqi_price * this.choose_num;
			this.data1 = null;
			// if(	this.usedBalances ==1){
			// 	if(this.prices>=0.1 *this. xinxidata.usedBalances){
			// 		this.needPay=this.prices-0.1 *this. xinxidata.usedBalances;
			// 	}else{
			// 		this.needPay=0
			// 	}
			// }else{
			// 		this.needPay=this.prices
			// }
			this.updataPrice();
			this.getAvailableQuantity();
		},
		// 布艺清洗
		onInput(e) {
			if (parseInt(e.detail.value) < 40) {
				this.fuheNum = 1;
				this.isShow = true;
			} else {
				this.fuheNum = 0;
				this.isShow = false;
			}
			this.yhj_sy = '';
			this.price_ss = e.detail.value * this.xinxidata.univalence;
			this.prices = this.prices_sc.minAdditionalPrice + this.price_ss;
			this.data1 = null;
			if (this.usedBalances == 1) {
				if (this.prices >= 0.1 * this.xinxidata.usedBalances) {
					this.needPay = this.prices - 0.1 * this.xinxidata.usedBalances;
				} else {
					this.needPay;
				}
			} else {
				this.needPay = this.prices;
			}
			this.getAvailableQuantity();
		},
		onInput2(e) {
			this.yhj_sy = '';
			this.prices_sc.minAdditionalPrice = e.detail.value * parseFloat(this.additional[0].additionalPrice);
			// this.price_addfj=e.detail.value *1

			this.prices = this.prices_sc.minAdditionalPrice + this.price_ss;
			this.data1 = null;
			if (this.usedBalances == 1) {
				if (this.prices >= 0.1 * this.xinxidata.usedBalances) {
					this.needPay = this.prices - 0.1 * this.xinxidata.usedBalances;
				} else {
					this.needPay;
				}
			} else {
				this.needPay = this.prices;
			}
			this.getAvailableQuantity();
		},
		getType() {
			let _this = this;
			let opts = {
				way: true, //true JSON请求；false 表单请求
				method: 'post',
				url: 'business/getBusinessSpecific'
			};
			let data = {
				employeeId: _this.employeeId,
				businessId: _this.businessId
			};
			_this.http.httpTokenRequest(opts, data).then(res => {
				if (res.code == 200) {
					_this.typeLists = res.data;
				} else {
					this.$refs.uToast.show({
						title: res.message,
						type: 'error'
					});
				}
			});
		},
		getPrice() {
			let _this = this;
			let opts = {
				way: true, //true JSON请求；false 表单请求
				method: 'post',
				url: 'business/getSpecificByBusiness'
			};
			let data = {
				businessId: _this.businessId
			};
			_this.http.httpTokenRequest(opts, data).then(res => {
				if (res.code == 200) {
					_this.maxPrice = res.data.maxPrice;
					_this.minPrice = res.data.minPrice;
				} else {
					this.$refs.uToast.show({
						title: res.message,
						type: 'error'
					});
				}
			});
		},
		getZcxd() {
			let _this = this;
			//再次下单获取员工单价
			let opts = {
				way: true, //true JSON请求；false 表单请求
				method: 'post',
				url: 'orders/getPriceByBusinessId'
			};
			let data = {
				businessId: _this.businessId,
				employeeId: _this.employeeId
			};
			_this.http.httpTokenRequest(opts, data).then(res => {
				if (res.code == 200) {
					if (_this.chargeType == 1 && _this.orderType != 2) {
						_this.rcbjPrice = res.data.price[0].univalence;
					} else if (_this.chargeType == 2) {
						_this.rcbjPrice = res.data.price[0].univalence;
					}
				}
			});
		},
		fast() {
			var _this = this;
			if (this.titleName == '玻璃清洗') {
				if (this.area_sc == '') {
					this.businessAdditional = [];
				} else {
					this.businessAdditional = [
						{
							additionalId: this.additional[0].additionalId || '',
							additionalAmount: this.area_sc
						}
					];
				}
			}
			if (_this.tims == '' && _this.chargeType == 1) {
				_this.$refs.uToast.show({
					title: '请选择服务时长'
				});
			} else if (_this.specificId == '' && _this.chargeType == 3) {
				_this.$refs.uToast.show({
					title: '请选择服务时长'
				});
			} else if (_this.area == '' && _this.chargeType == 2) {
				_this.$refs.uToast.show({
					title: '请输入面积'
				});
			} else if (_this.result == '请选择时间') {
				_this.isShow = true;
			} else if(_this.area < 40 && _this.businessId=='28'){
				_this.isShow = true;
				return false;
			}else{
				_this.loding_istrue = true;

				// uni.showModal({
				// 	title: '提示',
				// 	content: '确定下单吗？',
				// 	cancelText: '取消', // 取消按钮的文字
				// 	confirmText: '确认', // 确认按钮文字
				// 	confirmColor: '#F29423',
				// 	cancelColor: '#979797',
				// 	success: function(res) {
				// 		if (res.confirm) {
				if (_this.is_zhifu == true) {
					_this.is_zhifu = false;
					let opts = {
						way: true, //true JSON请求；false 表单请求
						method: 'post',
						url: 'unit-orders/creatDailyOrder'
					};
					let data = {
						businessId: _this.businessId,
						specificId: _this.specificId,
						enterpriseId: _this.enterpriseId,
						amount: _this.tims || _this.area || _this.choose_num,
						userAddressId: _this.address.addressId,
						startTime: _this.result,
						couponId: _this.userCouponId,
						usedBalances: _this.usedBalances,
						businessAdditional: _this.businessAdditional
					};
					_this.http.httpTokenRequest(opts, data).then(res => {
						if (res.code == 200) {
							_this.is_zhifu = true;
							var needstr = res.data;
							uni.requestSubscribeMessage({
								tmplIds: ['IdSIZcF3KlfXRiP4wvU4jwt6hu2tU2LnbsUPfF_Tq80', 'EjQNBMRd3C1y7Y1OMAyLn7sLsRNoolBBV42v1btLchw'],
								success(res) {
									_this.loding_istrue = false;
									if (needstr.needPay == 0) {
										uni.navigateTo({
											url: '../order/paySucess?type=1' + '&orderId=' + needstr.orderId
										});
									} else {
										_this.wxpay(needstr.vxPayData, needstr.orderId);
									}
								},
								fail(err) {
									_this.loding_istrue = false;
									if (needstr.needPay == 0) {
										uni.navigateTo({
											url: '../order/paySucess?type=1' + '&orderId=' + needstr.orderId
										});
									} else {
										_this.wxpay(needstr.vxPayData, needstr.orderId);
									}
								}
							});
						} else {
							_this.loding_istrue = false;
							_this.is_zhifu = true;
							_this.$refs.uToast.show({
								title: res.message,
								type: 'error'
							});
						}
					});
				}
				// 		}
				// 	}
				// });
			}
		},
		wxpay(str, orderId) {
			let _this = this;
			let query = str;
			uni.requestPayment({
				provider: 'wxpay',
				appId: query.appId,
				timeStamp: query.timeStamp + '',
				nonceStr: query.nonceStr,
				package: query.package,
				signType: query.signType,
				paySign: query.sign,
				success: res => {
					setTimeout(function() {
						uni.navigateTo({
							url: '../order/paySucess?type=1' + '&orderId=' + orderId
						});
					}, 1000);
				},
				fail: val => {
					_this.is_zhifu = true;
					_this.$refs.uToast.show({
						title: '支付失败',
						type: 'error'
					});
				}
			});
		},

		// 请选择时间
		getDatas() {
			var arr = [];
			var _this = this;
			var date = new Date();
			var year = date.getFullYear();
			var mon = date.getMonth() + 1;
			var day = date.getDate();
			if (mon <= 9) {
				//如果小于9的话，则需要加上0
				mon = '0' + mon;
			} //getdate()返回的是1-31，则不需要加1
			if (day <= 9) {
				//如果小于9的话，则需要加上0
				day = '0' + day;
			}
			var showDate = year + '-' + mon + '-' + day;
			var nextData = '';
			for (var i = 1; i <= 6; i++) {
				//后7天
				date.setDate(date.getDate() + 1);
				var mons = date.getMonth() + 1;
				if (mons <= 9) {
					mons = '0' + mons;
				}
				var days = date.getDate();
				if (days <= 9) {
					days = '0' + days;
				}
				nextData = date.getFullYear() + '-' + mons + '-' + days;
				arr.push({
					value: i + 1,
					label: nextData
				});
			}
			var datas = [
				{
					value: 1,
					label: '07:00'
				},
				{
					value: 2,
					label: '08:00'
				},
				{
					value: 3,
					label: '09:00'
				},

				{
					value: 4,
					label: '10:00'
				},
				{
					value: 5,
					label: '11:00'
				},
				{
					value: 6,
					label: '12:00'
				},
				{
					value: 7,
					label: '13:00'
				},
				{
					value: 8,
					label: '14:00'
				},

				{
					value: 9,
					label: '15:00'
				},
				{
					value: 10,
					label: '16:00'
				},
				{
					value: 11,
					label: '17:00'
				},
				{
					value: 12,
					label: '18:00'
				},
				{
					value: 13,
					label: '19:00'
				}
			];
			var nowtime = date.getHours();
			var indexs = null;
			datas.forEach((item, index) => {
				var tex = parseInt(item.label.substring(0, 2));
				if (parseInt(item.label.substring(0, 2)) == nowtime) {
					indexs = index;
				}
			});
			this.arrayInex = datas.splice(0, indexs + 1);
			var items = [];
			if (19 > nowtime) {
				items.push({
					value: 1,
					label: showDate
				});
			}
			items = items.concat(arr);
			items.forEach((item, index) => {
				if (index == 0 && datas.length > 0) {
					item.children = datas;
				} else {
					item.children = [
						{
							value: 1,
							label: '07:00'
						},
						{
							value: 2,
							label: '08:00'
						},
						{
							value: 3,
							label: '09:00'
						},

						{
							value: 4,
							label: '10:00'
						},
						{
							value: 5,
							label: '11:00'
						},
						{
							value: 6,
							label: '12:00'
						},
						{
							value: 7,
							label: '13:00'
						},
						{
							value: 8,
							label: '14:00'
						},

						{
							value: 9,
							label: '15:00'
						},
						{
							value: 10,
							label: '16:00'
						},
						{
							value: 11,
							label: '17:00'
						},
						{
							value: 12,
							label: '18:00'
						},
						{
							value: 13,
							label: '19:00'
						}
					];
				}
			});
			this.list = items;
		}
	}
};
</script>

<style scoped lang="scss">
.head {
	background: #ffffff;
	// box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
	opacity: 1;
	width: 91%;
	margin: auto;
	// border-radius: 5px;
	// margin: 22rpx 48rpx;
	// padding: 0rpx 26rpx;
	padding: 20rpx 0rpx;
	color: #3f3f3f;
	font-size: 30rpx;
	font-weight: 400;
}

.fenlei {
	display: flex;
	flex-wrap: wrap;
	// padding: 16rpx 24rpx 0 42rpx;
}
.type {
	background: #ffffff;
	// border: 1px solid #fca800;
	opacity: 1;
	// border-radius: 52rpx;
	padding: 0 13px;
	line-height: 74rpx;
	font-size: 26rpx;
	text-align: center;
	font-family: PingFang SC;
	font-weight: 400;
	margin-right: 20rpx;
	margin-top: 20rpx;
	border-radius: 10rpx;
}

.type image {
	width: 32rpx;
	height: 32rpx;
	position: absolute;
	bottom: -20%;
	right: -10%;
}

.fen_type .tai {
	font-size: 30rpx;
}

.serve {
	font-size: 26rpx;
	color: #3f3f3f;
	font-weight: 400;
	display: flex;
	// justify-content: space-between;
	align-items: center;
	margin-top: 20rpx;
}

.fuwu {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.fuwu image {
	width: 10rpx;
	height: 18rpx;
}

.dizhi {
	width: 450rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 26rpx;
	color: #7a7a7a;
	font-weight: 400;
}

.contact {
	margin-top: 22rpx;
}

.contact .namm {
	// padding-left: 16rpx;
	font-size: 30rpx;
	color: #7a7a7a;
	font-weight: bold;
}
.contact .ads {
	padding-left: 25rpx;
	font-size: 26rpx;
}

.xiang {
	width: 200rpx;
	font-size: 26rpx;
}

.biaozhu {
	color: #f86565;
	display: flex;
	align-items: center;
	font-size: 26rpx;
	height: 64rpx;
	padding-left: 28rpx;
	padding-right: 18rpx;
	background-color: #fff4de;
	line-height: 62rpx;
}
.biaozhus {
	color: #f86565;
	display: flex;
	align-items: center;
	font-size: 26rpx;
	height: 64rpx;
	padding-left: 28rpx;
	padding-right: 90rpx;
	line-height: 64rpx;
}
.biaozhus image {
	width: 29rpx;
	height: 29rpx;
}
.biaozhu image {
	width: 29rpx;
	height: 29rpx;
}

.choose {
	width: 91%;
	margin: auto;
	font-size: 30rpx;
	color: #3f3f3f;
	font-weight: 400;
	margin-top: 32rpx;
}

.biao_zhu {
	color: #979797;
	padding: 12rpx 0 20rpx 64rpx;
	font-size: 26rpx;
	margin-top: 92rpx;
}

.zhu {
	font-size: 30rpx;
}

.biao_zhu .write {
	padding-right: 182rpx;
	margin-top: 20rpx;
	line-height: 36rpx;
}

.time {
	display: flex;
	align-items: center;
	width: 91%;
	margin: auto;
	margin-top: 32rpx;
}

.start {
	font-size: 30rpx;
	color: #3f3f3f;
	font-weight: 400;
}

.xuanze {
	display: flex;
	text-align: right;
	width: 50%;
}

.xuanze view {
	width: 90%;
	line-height: 32rpx;
	color: #979797;
}

.xuanze image {
	width: 18rpx;
	height: 30rpx;
}

.t_img {
	width: 24rpx;
	height: 40rpx;
}

.footer {
	// height: 112rpx;
	position: fixed;
	z-index: 99;
	bottom: 0;
	width: 100%;
	background: #ffffff;
	opacity: 1;
}

.foot_mon {
	display: flex;
	justify-content: space-between;
	align-items: center;
	// padding: 26rpx 38rpx 20rpx 40rpx;
}

.writes {
	font-size: 38rpx;
	font-weight: 500;
}

.writes text {
	color: #fa5151;
}

.fen_types {
	display: flex;
	align-items: center;
	color: #3f3f3f;
	font-size: 40rpx;
}

.fen_types input {
	width: 164rpx;
	// height: 104rpx;
	// margin: 30rpx 36rpx 28rpx 48rpx;
	// box-shadow: 0px 3rpx 6rpx rgba(241, 179, 10, 0.33);
	// border-radius: 10rpx;
	padding: 0 20rpx;
	border-bottom: 2rpx solid #b8b7b7;
}

.fenlei .acts {
	color: #fc8a17;
	border: 2rpx solid #fc8a17;
	// box-shadow: 0px 3rpx 6rpx rgba(241, 179, 10, 0.37);
	// background-color: #fca800;
}
.fenlei .acts_2 {
	border: 2rpx solid #c2c2c2;
}

.actss {
	color: #fca800;
}
</style>
